import axios from 'axios';
import type { TableData } from '@arco-design/web-vue/es/table/interface';
import baseUrl from '../config';

export interface ContentDataRecord {
  x: string;
  y: number;
}

export function queryContentData(employee, taskId, period) {
  // 如果employee为空或未定义，则传递'total'
  const employeeParam = employee || 'total';
  // if (taskId == null || taskId === '') {
  //   taskId = 539;
  // }
  const url = `${baseUrl}/api/dashboard?employee=${employeeParam}&task_id=${taskId}&period=${period}`;
  console.log(url);
  return axios.get(url);
}

export function queryEmployeeData(taskId, employeeNo, period) {
  // const baseUrl = import.meta.env.VITE_API_BASE_URL;  // 动态获取 API 地址
  // if (taskId == null || taskId === '') {
  //   taskId = 539;
  // }
  const url = `${baseUrl}/api/dashboard_employee?task_id=${taskId}`;
  console.log(url);
  return axios.get(url);
}

export interface PopularRecord {
  key: number;
  clickNumber: string;
  title: string;
  increases: number;
}

export function queryPopularList(params: { type: string }) {
  return axios.get<TableData[]>('/api/popular/list', { params });
}
